package viewmodel;

import model.Bet;
import model.BetDecisionType;
import model.BetStatus;
import model.BetVisibility;
import android.app.betmein.view.DisplayBetView;
import android.content.Context;
import android.framework.binding.Binding;
import android.framework.binding.converters.ConverterDateString;
import android.framework.binding.converters.ConverterIntegerString;
import android.framework.binding.converters.IConverter;
import android.framework.paging.BaseViewModel;

public class DisplayBetViewModel extends BaseViewModel<DisplayBetView>{

	
	private Bet bet;
	
	public DisplayBetViewModel(Context context, Bet bet) {
		super(context);
		this.bet = bet;
	}

	public DisplayBetViewModel(Context context) {
		super(context);
	}

	@Override
	public void onInit() {
		Binding.attached(bet.getTitle(), getView().betTitle);
		Binding.attached(bet.getDescription(), getView().betDescription);
		Binding.attached(bet.getBetAmount(), getView().betAmount, new ConverterIntegerString());
		Binding.attached(bet.getDecisionType(), getView().betDecsitionType, new IConverter<BetDecisionType, String>() {public String convertTo(BetDecisionType value) {return value.toString();}public BetDecisionType convertFrom(String value) {return Enum.valueOf(BetDecisionType.class, value);}});
		Binding.attached(bet.getBetVisibility(), getView().betVisibility, new IConverter<BetVisibility, String>() {public String convertTo(BetVisibility value) {return value.toString();}public BetVisibility convertFrom(String value) {return Enum.valueOf(BetVisibility.class, value);}});
		Binding.attached(bet.getBetStatus(), getView().betStatus, new IConverter<BetStatus, String>() {public String convertTo(BetStatus value) {return value.toString();}public BetStatus convertFrom(String value) {return Enum.valueOf(BetStatus.class, value);}});
		Binding.attached(bet.getLastDateForBet(), getView().lastDateForPlaceBet, new ConverterDateString());
		Binding.attached(bet.getDecisionTime(), getView().betDecsitionTime, new ConverterDateString());
	}

}
